'''
    1 元素个数统计
    2 所有元素的text获取--列表
    3 获取input的value
    3 获取元素属性值


'''

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto('https://www.baidu.com/s?wd=%E9%97%AE%E8%B4%A2%E5%AE%98%E7%BD%91&rsv_spt=1&rsv_iqid=0xd87ee3d00005eb9b&issp=1&f=3&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=88093251_56_hao_pg&rsv_enter=1&rsv_dl=ts_2&oq=test&rsv_btype=t&inputT=7977&rsv_t=67a2XFoCaZb3AgUwpYqCuvskyMOxJl471bX6YqVjKDSuJp1gdQAjyRbfWv4A3mlmm3LnWZ2y%2FbDH&rsv_pq=aeba19da00216820&rsv_sug3=12&rsv_sug1=12&rsv_sug7=101&rsv_sug2=1&prefixsug=wencai&rsp=2&rsv_sug4=7977')
    page.wait_for_timeout(2000)
    loc = page.locator('//h3')


    print(loc.count())
    print(loc.all_text_contents())

    su = page.locator('#su')
    print(1,su.input_value())
    print(2,su.get_attribute('type'))
    print(2,su.get_attribute('value'))
